home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / educate / uucpprot.txt < prev    next >
Text File  |  1992-09-04  |  29KB  |  1,044 lines

  1.  
  2. [This information came from the Tanner Andrews's uucpinfo mailing list.
  3. This is a collection of people interested in writing a version
  4. of uucp in the public domain.  Contact ihnp4!akgua!ucf-cs!ki4pv!tanner
  5. to be added to the mailing list.  There have only been three messages
  6. sent to the list; all are below.
  7.  
  8.     John Gilmore, hoptoad!gnu]
  9.  
  10. -----
  11.  
  12. Subject: UUCP Protocol Information (issue #1)
  13. Date: Tue Nov 19 22:04:56 1985
  14.  
  15. Greetings.  First order of business is the fact that I probably have
  16. a lousy or a slow address for some of you all.  Please complain, and
  17. things will be corrected.  Those of you not receiving this because your
  18. names have been omitted will please inform me, giving a good address.
  19. Those who provided replies but who are not interested in receiving
  20. further information please warn me; maybe things won't cross in the
  21. mail.
  22.  
  23. Now that we're over that, welcome to the first issue.  There will most
  24. likely be more, as more information is received.  Anyone with comments,
  25. information, or clean suggestions to be shared should please write to
  26. me at the return address given below.  I'll keep the copy of this
  27. mailing list around, and make required additions, deletions, &c.  This
  28. issue is just a "welcome" and mailing-error-finder.  Sorry about the
  29. delay between your "me-too" mailing and the actual goodstuff.
  30.  
  31. This is being issued as a mailing list because, while I have some of
  32. the required information, there is still rather a shortage.  Research
  33. is expected to improve the situation.
  34.  
  35. The second issue of this will be coming out almost immediately, and
  36. will contain the bulk of the preliminary information which I have.
  37. It will also include a summary which has been tempered by experience
  38. on this system (type ~uucp_adm/uucico on my terminal, watch the fun
  39. begin).
  40.  
  41. My address is:
  42.     uucp:    ...{decvax|akgua}!ucf-cs!ki4pv!tanner
  43.     csnet:    ki4pv!tanner@ucf-cs.csnet
  44.     arpa:    ki4pv!tanner%ucf-cs.csnet@csnet-relay.arpa
  45.  
  46.                         Tanner Andrews, systems
  47.                         CompuData South,
  48.                         P.O.Box 3636,
  49.                         DeLand, FLA   32723.
  50.  
  51. From: ihnp4!akgua!ucf-cs!ki4pv!tanner
  52. To: ucf-cs!ki4pv-uucpinfo2, ucf-cs!ki4pv-uucpinfo1
  53. Subject: UUCP Information Issue #02
  54. Date: Wed Dec 11 23:39:26 1985
  55.  
  56. This is the second issue; the information below is the start of
  57. what has been collected here.  It is expected that more information
  58. will be collected in the next few weeks, and that information will
  59. be forwarded when/if it becomes available.
  60.  
  61.  =====================================================
  62.  -- part 1
  63.  =====================================================
  64. This information came via several people, most of whom snet this
  65. exact message (probably from their news archives from before we
  66. joined the net):
  67.  
  68.     I am posting this over the network because I believe that
  69.     others are interested in knowing the protocols of UUCP.
  70.     Below is listed all the information that I have acquired
  71.     to date. This includes the initial handshaking phase, though
  72.     not the login phase. It also doesn't include information
  73.     about the data transfer protocol for non-packet networks
  74.     (the -G option left off the uucico command line). But, just
  75.     hold on - I am working on that stuff.
  76.  
  77.     For a point of information : the slave is the UUCP site being
  78.     dialed, and the master is the one doing the calling up. The
  79.     protocols listed in the handshaking and termination phase are
  80.     independent of any UUCP site : it is universal. The stuff in
  81.     the work phase depends on the specific protocol chosen. The
  82.     concepts in the work phase are independent of protocol, ie. the
  83.     sequences are the same. It is just the lower level stuff that
  84.     changes from protocol to protocol. I have access only to level
  85.     g and will document it as I begin to understand it.
  86.  
  87.     Most of the stuff you see here is gotten from the debug phase
  88.     of the current BSD UUCP system.
  89.  
  90.     I hope this is useful. Maybe this will get some of the real
  91.     'brains' in UUCP to get off their duffs and provide some real
  92.     detail. In any case, if you have any questions please feel
  93.     free to contact me. I will post any questions and answers over
  94.     the network.
  95.  
  96.  
  97.                 Chuck Wegrzyn
  98.                 {allegra,decvax,ihnp4}!encore!wegrzyn
  99.  
  100.                 (617) 237-1022
  101.  
  102.  
  103.  
  104.             UUCP Handshake Phase
  105.             ====================
  106.  
  107. Master                            Slave
  108. ------                            -----
  109.  
  110.                     <-----        \020Shere\0     (1)
  111.  
  112.  
  113. (2)  \020S<mastername> <switches>\0    ----->
  114.  
  115.  
  116.                     <-----        \020RLCK\0      (3)
  117.                             \020RCB\0
  118.                             \020ROK\0
  119.                             \020RBADSEQ\0
  120.  
  121.                     <-----        \020P<protos>\0 (4)
  122.  
  123.  
  124. (5) \020U<proto>\0            ----->
  125.     \020UN\0
  126.  
  127.  
  128. (6) ...
  129.  
  130.  
  131. (0) This communication happens outside of the packet communication that
  132.     is supported. If the -G flag is sent on the uucico line, all
  133.     communications will occur without the use of the packet
  134.     simulation software. The communication at this level is just
  135.     the characters listed above.
  136.  
  137. (1) The slave sends the sequence indicated, while the master waits for
  138.     the message.
  139.  
  140. (2) The slave waits for the master to send a response message. The message
  141.     is composed of the master's name and some optional switches.
  142.     The switch field can include the following
  143.  
  144.             -g        (set by the -G switch on the
  145.                      master's uucico command line.
  146.                      Indicates that communication
  147.                      occurs over a packet switch net.)
  148.             -xN        (set by the -x switch on the
  149.                      master's uucico command line.
  150.                      The number N is the debug level
  151.                      desired.)
  152.             -QM        (M is really a sequence number
  153.                      for the communication.)
  154.  
  155.     Each switch is separated from the others by a 'blank' character.
  156.  
  157. (3) The slave will send one of the many responses. The meanings appear to
  158.     be :
  159.  
  160.     RLCK
  161.  
  162.         This message implies that a 'lock' failure occurred:
  163.         a file called LCK..mastername couldn't be created since
  164.         one already exists. This seems to imply that the master
  165.         is already in communication with the slave.
  166.  
  167.     RCB
  168.  
  169.         This message will be sent out if the slave requires a
  170.         call back to the master - the slave will not accept a
  171.         call from the master but will call the master instead.
  172.  
  173.     ROK
  174.  
  175.         This message will be returned if the sequence number that
  176.         was sent in the message, attached to the -Q switch, from 
  177.         the master is the same as that computed on the slave.
  178.  
  179.     RBADSEQ
  180.  
  181.         Happens if the sequence numbers do not match.
  182.  
  183.     (Notes on the sequence number - if a machine does not keep
  184.      sequence numbers, the value is set to 0. If no -Q switch
  185.      is given in the master's line, the sequence number is
  186.      defaulted to 0.
  187.  
  188.      The sequence file, SQFILE, has the format
  189.  
  190.         <remotename> <number> <month>/<day>-<hour>:<min>
  191.  
  192.      where <remotename> is the name of a master and <number>
  193.      is the previous sequence number. If the <number> field
  194.      is not present, or if it is greater than 9998, it is
  195.      set to 0. The <number> field is an ascii representation
  196.      of the number. The stuff after the <number> is the time
  197.      the sequence number was last changed, this information
  198.      doesn't seem important.)
  199.  
  200. (4) The slave sends a message that identifies all the protocols that
  201.     it supports. It seems that BSD supports 'g' as the normal case.
  202.     Some sites, such as Allegra, support 'e' and 'g', and a few
  203.     sites support 'f' as well. I have no information about these
  204.     protocols. The exact message sent might look like
  205.  
  206.         \020Pefg\0
  207.  
  208.     where efg indicates that this slave supports the e,f and g 
  209.     protocols.
  210.  
  211. (5) The slave waits for a response from the master with the chosen
  212.     protocol. If the master has a protocol that is in common the
  213.     master will send the message
  214.  
  215.         \020U<proto>\0
  216.  
  217.     where <proto> is the protocol (letter) chosen. If no protocol
  218.     is in common, the master will send the message
  219.  
  220.         \020UN\0
  221.  
  222. (6) At this point both the slave and master agree to use the designated
  223.     protocol. The first thing that now happens is that the master
  224.     checks for work.
  225.  
  226. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  227.  
  228.             UUCP Work Phase
  229.             ===============
  230.  
  231.  
  232. Master                            Slave
  233. ------                            -----
  234.  
  235. (a) Master has UUCP Work
  236.  
  237.     (1) X file1 file2     ----->
  238.  
  239.                     <-----        XN        (2)
  240.                             XY
  241.  
  242.     When the master wants the slave to do a 'uux' command
  243.     it sends the X message. If the slave can't or won't
  244.     do it, the slave will send an XN message. Otherwise
  245.     it will send an XY message.
  246.  
  247. (b) Master wants to send a file
  248.  
  249.     (1) S file1 file2 user options  ----->
  250.  
  251.                     <-----        SN2        (2)
  252.                             SN4
  253.                             SY
  254.  
  255.             <---- <data exchanged>---->            (3)
  256.  
  257.  
  258.                     <-----        CY        (4)
  259.                             CN5
  260.  
  261.     If the master wishes to send a file to the slave, it will
  262.     send a S message to the slave. If the slave can or will do
  263.     the transfer, it sends a SY message. If the slave has a
  264.     problem creating work files, it sends a SN4 message. If
  265.     the target file can't be created (because of priv's etc)
  266.     it sends a SN2 message.
  267.  
  268.     The file1 argument is the source file, and file2 is the
  269.     (almost) target filename. If file2 is a directory, then
  270.     the target filename is composed of file2 concatenated
  271.     with the "last" part of the file1 argument. Note, if the
  272.     file2 argument begins with X, the request is targeted to
  273.     UUX and not the normal send.
  274.  
  275.     The user argument indicates who, if anyone, is to be notified
  276.     if the file has been copied. This user must be on the slave
  277.     system.
  278.  
  279.     I am not sure what the options argument does.
  280.  
  281.     After the data has been exchanged the slave will send one of
  282.     two messages to the master. A CY message indicates that every-
  283.     thing is ok. The message CN5 indicates that the slave had
  284.     some problem moving the file to it's permanent location. This
  285.     is not the same as a problem during the exchange of data : this
  286.     causes the slave to terminate operation.
  287.  
  288. (c) Master wishes to receive a file.
  289.  
  290.     (1) R file1 file2 user    ----->
  291.  
  292.                         <-----    RN2        (2)
  293.                             RY mode
  294.  
  295.     (3)        <---- <data exchanged> ---->
  296.  
  297.     (4)    CY        ----->
  298.         CN5
  299.  
  300.     If the master wishes the slave to send a file, the master sends
  301.     a R message. If the slave has the file and can send it, the
  302.     slave will respond with the RY message. If the slave can't find
  303.     the file, or won't send it the RN2 message is sent. It doesn't
  304.     appear that the 'mode' field of the RY message is used.
  305.  
  306.     The argument file1 is the file to transfer, unless it is a
  307.     directory. In this case the file to be transferred is built
  308.     of a concatenation of file1 with the "last" part of the file2
  309.     argument.
  310.  
  311.     If anything goes wrong with the data transfer, it results in
  312.     both the slave and the master terminating.
  313.  
  314.     After the data has been transferred, the master will send an
  315.     acknowledgement to the slave. If the transfer and copy to the
  316.     destination file has been successful, the master will send the
  317.     CY message. Otherwise it will send the CN5 message.
  318.  
  319. (d) Master has no work, or no more work.
  320.  
  321.     (1) H            ----->
  322.  
  323.                 <-----                HY    (2)
  324.                                 HN
  325.  
  326.     (3) HY            ----->
  327.  
  328.                 <----                HY    (4)
  329.  
  330.     (5) ...
  331.  
  332.     The transfer of control is initiated with the master sending
  333.     a H message. This message tells the slave that the master has
  334.     no work, and the slave should look for work.
  335.  
  336.     If the slave has no work it will respond with the HY message.
  337.     This will tell the master to send an HY message, and turn off
  338.     the selected protocol. When the HY message is received by the
  339.     slave, it turns off the selected protocol as well. Both the
  340.     master and slave enter the UUCP termination phase.
  341.  
  342.     If the slave does have work, it sends the HN message to the
  343.     master. At this point, the slave becomes the master. After
  344.     the master receives the HN message, it becomes the slave.
  345.     The whole sequence of sending work starts over again. Note,
  346.     the transmission of HN doesn't force the master to send any
  347.     other H messages : it waits for stuff  from the new master.
  348.  
  349. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  350.  
  351.  
  352.             UUCP Termination Sequence
  353.             =========================
  354.  
  355.  Master                                Slave
  356.  ------                                -----
  357.  
  358.  (1) \020OOOOOO\0        ----->
  359.  
  360.                 <-----            \020OOOOOOO\0 (2)
  361.  
  362.  
  363.  
  364.     At this point all conversation has completed normally.
  365.  
  366.  
  367. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  368.  
  369.             UUCP Data Transfers
  370.             ===================
  371.  
  372.     After the initial handshake the systems send messages in one
  373.     of two styles : packet and not packet. A Packet protocol is
  374.     just raw data transfers : there is no protocol or acknowledgements;
  375.     this appears to assume that the lower level is a packet network
  376.     of some type. If the style is not Packet, then extra work is
  377.     done. I am still working on this stuff.
  378.  
  379.  =====================================================
  380.  -- part 2
  381.  =====================================================
  382.  ** summary of UUCP packets ** 
  383. (this is much like part 1, but shortened and compared against a
  384. live UUCP ~uucp_adm/uucico)
  385.  
  386. note that all transmissions end with a null, not shown here
  387.  
  388.  
  389. (master)        (slave)
  390.  
  391.  ... dials up ...    <DLE>Shere        says "hello"
  392.  
  393. <DLE>S<sysname> <opts>                says who he is
  394.  
  395.         |    <DLE>ROK        says ok to talk
  396.         |    <DLE>RLCK        says locked out
  397.         |    <DLE>RCB        says will call back
  398.         |    <DLE>RBADSEQ        says bad seq num
  399.  
  400.             <DLE>P<protos>        what protocols he has
  401.  
  402. <DLE>U<proto>    |                which to use
  403. <DLE>UN        |                use none, hang up
  404.  
  405.  
  406. packet driver is turned on at this time, if not told otherwise
  407.  
  408.  -- if master has work --
  409.  
  410. to sned file to slave...
  411. S <mfilenm> <sfilenm> <user> <opts>        request to sned file
  412.  
  413.         |    SY            ok -- i'll take it
  414.         |    SN2            not permitted
  415.         |    SN4            can't make workfile
  416.  
  417. <data>                        the file is transmitted
  418.  
  419.         |    CY            finished OK
  420.         |    CN5            can't move into place
  421.  
  422.  
  423. to recv file from slave...
  424. R <sfilenm> <mfilenm> <user>            request to recv file
  425.  
  426.         |    RY<mode>        ok -- here is prot mode
  427.         |    RN2            not permitted
  428.  
  429.             <data>            file is transmitted
  430.  
  431. CY        |                worked
  432. CN5        |                can't move into place
  433.  
  434.  
  435. to do UUX on slave...
  436. X <file1> <file2>                request to exec file
  437.  
  438.         |    XY            ok -- will do
  439.         |    XN            nopers
  440.  
  441. to indicate that he has no more work...
  442. H                        no more work
  443.  
  444.         |    HN            reverse roles
  445.         |    HY            no work here either
  446.  
  447. to accept slave's claim of no more work...
  448.  
  449. HY                        agrees to hang up
  450.  
  451. the rest of the hang-up is done OUTSIDE of packet driver
  452. <DLE>OOOOOO                    signs off (6*'O')
  453.  
  454.             <DLE>OOOOOOO        signs off (7*'O')
  455.     
  456.  
  457. If the slave has work, then the roles are reversed, and the
  458. session proceeds from the label 'loop1' above.  The system
  459. which was the slave is now the master, and the old master is
  460. just the slave.
  461.  
  462. The <opts> which follow the system name for the start-up sequence
  463. include:
  464.     -g        don't use packet driver (command line -G)
  465.     -xN        debug level (command line -Xn)
  466.     -QN        seq number (if systems use this)
  467.  
  468. The filenames for <mfilenm> should be complete filenames with
  469. path information; otherwise they are assumed to be in /usr/spool/uucp.
  470. The filenames for <sfilenm> should be either complete filenames
  471. or directory names.  If directory names are used, then the final
  472. componant of <mfilenm> is appended to form the complete filename.
  473.  
  474. The 'X' command to do UUX on a slave is more than a little unclear.
  475. It doesn't seem to work here, but that may be a microsoft "feature".
  476.  
  477.  
  478. Protocol "g", which seems to be the one most commonly used, is supposed
  479. to be a slightly munged version of level 2 of X.25; an article was just
  480. posted in net.unix-wizards (which you probably have already seen) to
  481. this effect.  The article didn't provide any details on the protocol,
  482. but merely mentioned the modifications.
  483.  
  484. The "packet" mode, with no protocol, does not work under microsoft
  485. implementations, and may have *lots* of trouble working anywhere
  486. else as well.  It evidently requires that zero-length reads happen
  487. every so often to delimit things, such as files being transferred.
  488. This of course can't happen without the packet driver, which was long
  489. gone by the time sys-3 or sys-5 or <your current version> came along.
  490.  
  491. **********************************
  492. ** end of issue #2
  493. **********************************
  494.  
  495.  
  496. From: ihnp4!akgua!ucf-cs!ki4pv!tanner
  497. To: ucf-cs!ki4pv-uucpinfo, allegra!mp
  498. Subject: UUCP INFO mailing list issue #03
  499. Date: Sun Jan 12 19:11:18 1986
  500.  
  501. The following information, describing the uucp 'g' protocol, was
  502. provided as "nroff" source.  Cut the header and this text off of
  503. the message, and run it through "nroff".
  504. .ce
  505. .B
  506. Packet Driver Protocol
  507. .R
  508. .sp 1
  509. .ce
  510. G. L. Chesson
  511. .br
  512. .ce
  513. Bell Laboratories
  514. .SH
  515. Abstract
  516. .in +.5i
  517. .PP
  518. These notes describe the packet driver link
  519. protocol that was supplied
  520. with the
  521. Seventh Edition of
  522. .UX
  523. and is used by the UUCP program.
  524. .in -.5i
  525. .SH
  526. General
  527. .PP
  528. Information flow between a pair of machines
  529. may be regulated by
  530. first
  531. representing the data 
  532. as sequence-numbered 
  533. .I
  534. packets
  535. .R
  536. of data 
  537. and then establishing conventions that
  538. govern the use of sequence numbers.
  539. The
  540. .I
  541. PK,
  542. .R
  543. or
  544. .I
  545. packet driver,
  546. .R
  547. protocol
  548. is a particular instance of this type of
  549. flow-control discipline.
  550. The technique depends on the notion of a transmission
  551. .I
  552. window
  553. .R
  554. to determine upper and lower bounds for valid
  555. sequence numbers.
  556. The transmitter is allowed to retransmit packets
  557. having sequence numbers
  558. within the window until the receiver indicates that
  559. packets have been correctly received.
  560. Positive acknowledgement from the receiver moves the
  561. window;
  562. negative acknowledgement or no acknowledgement
  563. causes retransmission.
  564. The receiver must ignore duplicate transmission, detect
  565. the various errors that may occur,
  566. and inform the transmitter when packets are 
  567. correctly or incorrectly received.
  568. .PP
  569. The following paragraphs describe the packet formats,
  570. message exchanges,
  571. and framing
  572. used by the protocol as coded
  573. in the UUCP program and the
  574. .UX
  575. kernel.
  576. Although no attempt will be made here to present
  577. internal details of the algorithms that were used,
  578. the checksum routine is supplied
  579. for the benefit of other implementors.
  580. .SH
  581. Packet Formats
  582. .PP
  583. The protocol is defined in terms of message
  584. transmissions of 8-bit bytes.
  585. Each message includes one
  586. .I
  587. control
  588. .R
  589. byte plus a
  590. .I
  591. data segment
  592. .R
  593. of zero or more information bytes.
  594. The allowed data segment sizes range
  595. between 32 and 4096 as determined by the formula
  596. 32(2\uk\d) where
  597. k is a 3-bit number.
  598. The packet sequence numbers are likewise constrained
  599. to 3-bits; i.e. counting proceeds modulo-8.
  600. .PP
  601. The control byte is partitioned into three fields as
  602. depicted below.
  603. .bp
  604. .nf
  605. .sp 
  606. .in 1i
  607. .ls 1
  608. bit    7    6    5    4    3    2    1    0
  609.     t    t    x    x    x    y    y    y
  610. .ls 1
  611. .in -1i
  612. .fi
  613. .sp
  614. The
  615. .I
  616. t
  617. .R
  618. bits indicate a packet type and
  619. determine the interpretation to be placed on
  620. the
  621. .I
  622. xxx
  623. .R
  624. and
  625. .I
  626. yyy
  627. .R
  628. fields.
  629. The various interpretations are as follows:
  630. .in +1i
  631. .sp
  632. .nf
  633. .ls 1
  634. .I
  635. tt    interpretation
  636. .sp
  637. .R
  638. 00    control packet
  639. 10    data packet
  640. 11    `short' data packet
  641. 01    alternate channel
  642. .ls 1
  643. .fi
  644. .sp
  645. .in -1i
  646. A data segment accompanies all non-control packets.
  647. Each transmitter is constrained to observe the maximum
  648. data segment size
  649. established during initial synchronization by the
  650. receiver that it sends to.
  651. Type 10 packets have maximal size data segments.
  652. Type 11, or `short', packets have zero or more data
  653. bytes but less than the maximum.
  654. The first one or two bytes of the data segment of a
  655. short packet are `count' bytes that
  656. indicate the difference between the
  657. maximum size and the number of bytes in the short
  658. segment.
  659. If the difference is less than 127, one count
  660. byte is used.
  661. If the difference exceeds 127,
  662. then the low-order seven bits of the difference
  663. are put in the first data byte and the high-order
  664. bit is set as an indicator that the remaining
  665. bits of the difference are in the second byte.
  666. Type 01 packets are never used by UUCP
  667. and need not be discussed in detail here.
  668. .PP
  669. The sequence number of a non-control packet is
  670. given by the
  671. .I
  672. xxx
  673. .R
  674. field.
  675. Control packets are not sequenced.
  676. The newest sequence number,
  677. excluding duplicate transmissions,
  678. accepted by a receiver is placed in the
  679. .I
  680. yyy
  681. .R
  682. field of non-control packets sent to the
  683. `other' receiver.
  684. .PP
  685. There are no data bytes associated with a control packet,
  686. the
  687. .I
  688. xxx
  689. .R
  690. field is interpreted as a control message,
  691. and the
  692. .I
  693. yyy
  694. .R
  695. field is a value accompanying the control message.
  696. The control messages are listed below in decreasing priority.
  697. That is, if several control messages are to be sent,
  698. the lower-numbered ones are sent first.
  699. .in +1i
  700. .nf
  701. .ls 1
  702. .sp
  703. .I
  704. xxx    name        yyy
  705. .R
  706.  
  707. 1    CLOSE    n/a
  708. 2    RJ        last correctly received sequence number
  709. 3    SRJ        sequence number to retransmit
  710. 4    RR        last correctly received sequence number
  711. 5    INITC    window size
  712. 6    INITB    data segment size
  713. 7    INITA    window size
  714. .in -i
  715. .ls 1
  716. .fi
  717. .sp
  718. .PP
  719. The CLOSE message indicates that the communications channel
  720. is to be shut down.
  721. The RJ, or
  722. .I
  723. reject,
  724. .R
  725. message indicates that the receiver has detected an error
  726. and the sender should retransmit after using the 
  727. .I
  728. yyy
  729. .R
  730. field to update the window.
  731. This mode of retransmission is usually
  732. referred to as a
  733. `go-back-N' procedure.
  734. The SRJ, or
  735. .I
  736. selective reject,
  737. .R
  738. message carries with it the sequence number of
  739. a particular packet to be retransmitted.
  740. The RR, or
  741. .I
  742. receiver ready,
  743. .R
  744. message indicates that the receiver has detected
  745. no errors; the
  746. .I
  747. yyy
  748. .R
  749. field updates the sender's window.
  750. The INITA/B/C messages are used
  751. to set window and data segment sizes.
  752. Segment sizes are calculated by the formula
  753. 32(2\uyyy\d)
  754. as mentioned above,
  755. and window sizes may range between 1 and 7.
  756. .PP
  757. Measurements of the protocol running on communication
  758. links at rates up to 9600 baud showed that
  759. a window size of 2 is optimal
  760. given a packet size greater than 32 bytes.
  761. This means that the link bandwidth can be fully utilized
  762. by the software.
  763. For this reason the SRJ message is not as important as it
  764. might otherwise be.
  765. Therefore the
  766. .UX
  767. implementations no longer generate or respond to SRJ
  768. messages.
  769. It is mentioned here for historical accuracy only,
  770. and one may assume that SRJ is no longer part of the protocol.
  771. .SH
  772. Message Exchanges
  773. .SH
  774.     Initialization
  775. .PP
  776. Messages are exchanged between four cooperating
  777. entities: two senders and two receivers.
  778. This means that the communication channel is thought of
  779. as two independent half-duplex data paths.
  780. For example the window and segment sizes need not
  781. be the same in each direction.
  782. .PP
  783. Initial synchronization is accomplished
  784. with two 3-way handshakes: two each of
  785. INITA/INITB/INITC.
  786. Each sender transmits INITA messages repeatedly.
  787. When an INITA message is received, INITB is
  788. sent in return.
  789. When an INITB message is received
  790. .I
  791. and
  792. .R
  793. an INITB message has been sent,
  794. an INITC message is sent.
  795. The INITA and INITB messages carry 
  796. with them the packet and window size that
  797. each receiver wants to use,
  798. and the senders are supposed to comply.
  799. When a receiver has seen all three
  800. INIT messages, the channel is 
  801. considered to be open.
  802. .PP
  803. It is possible to design a protocol that starts up using
  804. fewer messages than the interlocked handshakes described above.
  805. The advantage of the more complicated design lies in its use as
  806. a research vehicle:
  807. the initial handshake sequence is completely symmetric,
  808. a handshake
  809. can be initiated by one side of the link while the
  810. connection is in use, and the software to do this can
  811. utilize code that would ordinarily be used only once
  812. at connection setup time.
  813. These properties were used in experiments with dynamically
  814. adjusted parameters.
  815. That is attempts were made to adapt the window and segment
  816. sizes to changes observed in traffic while a link was in use.
  817. Other experiments used the initial
  818. handshake  in a different way
  819. for restarting the protocol without data loss
  820. after machine crashes.
  821. These experiments never worked well in the packet driver and
  822. basically provided the impetus for other protocol designs.
  823. The result 
  824. as far as UUCP is concerned is that initial synchronization
  825. uses the two 3-way handshakes, and the INIT
  826. messages are ignored elsewhere.
  827. .SH
  828.     Data Transport
  829. .PP
  830. After initial synchronization each receiver
  831. sets a modulo-8 incrementing counter R to 0;
  832. each sender sets a similar counter S to 1.
  833. The value of R is always the number of the most recent
  834. correctly received packet.
  835. The value of S is always the first sequence number in
  836. the output window.
  837. Let W denote window size.
  838. Note that the value of W may be different for each sender.
  839. .PP
  840. A sender may transmit packets with sequence numbers
  841. in the range S to (S+W-1)\ mod-8.
  842. At any particular time a receiver expects
  843. arriving packets to have numbers in the range
  844. (R+1)\ mod-8 to (R+W)\ mod-8.
  845. Packets must arrive in sequence number order
  846. are are only acknowledged in order.
  847. That is,
  848. the `next' packet a receiver
  849. will acknowledge must have
  850. sequence number (R+1)\ mod-8.
  851. .PP
  852. A receiver acknowledges receipt of data packets
  853. by arranging for the value of its R counter to be
  854. sent across the channel
  855. where it will be used to update an S counter.
  856. This is done in two ways.
  857. If data is flowing in both directions across a
  858. channel then each receiver's current R value is
  859. carried in the
  860. .I
  861. yyy
  862. .R
  863. field of non-control packets.
  864. Otherwise when there is no bidirectional
  865. data flow,
  866. each receiver's R value is transmitted across the link
  867. as the
  868. .I
  869. yyy
  870. .R
  871. field of an RR control packet.
  872. .PP
  873. Error handling is up to the discretion
  874. of the receiver.
  875. It can ignore all errors in which case
  876. transmitter timeouts must provide for
  877. retransmission.
  878. The receiver may also generate RJ 
  879. error control packets.
  880. The
  881. .I
  882. yyy
  883. .R
  884. field of an incoming RJ message replaces
  885. the S value of the local sender and
  886. constitutes a request for retransmission to start
  887. at that sequence number.
  888. The
  889. .I
  890. yyy
  891. .R
  892. field of an incoming SRJ message selects a particular
  893. packet for retransmission.
  894. .PP
  895. The resemblance between the flow control procedure in the
  896. packet driver and that defined for X.25 is no accident.
  897. The packet driver protocol began life as an attempt at
  898. cleaning up X.25.
  899. That is why, for example,
  900. control information is uniform in length (one byte),
  901. there is no RNR message (not needed),
  902. and there is but one timeout defined
  903. in the sender.
  904. .SH
  905.     Termination
  906. .PP
  907. The CLOSE message is used to terminate communications.
  908. Software on either or both ends of the communication
  909. channel may initiate termination.
  910. In any case when one end wants to terminate it sends
  911. CLOSE messages until one is received from the other end
  912. or until a programmable limit on the number of CLOSE
  913. messages is reached.
  914. Receipt of a CLOSE message causes a CLOSE message to be sent.
  915. In the 
  916. .UX
  917. environment
  918. it also causes the SIGPIPE or
  919. `broken pipe' signal to be sent to
  920. the local process using the communication channel.
  921. .SH
  922.     Framing
  923. .PP
  924. The term
  925. .I
  926. framing
  927. .R
  928. is used to denote the technique by which the
  929. beginning and end of a message is detected
  930. in a byte stream;
  931. .I
  932. error control
  933. .R
  934. denotes the method by which transmission
  935. errors are detected.
  936. Strategies for framing and error control depend
  937. upon
  938. additional information being transmitted along
  939. with the control byte and data segment,
  940. and the choice of a particular strategy usually
  941. depends on characteristics of input/output
  942. devices and transmission media.
  943. .PP
  944. Several framing techniques are in used in support
  945. of PK protocol implementations,
  946. not all of which can be described in detail here.
  947. The technique used on asynchronous serial lines
  948. will be described.
  949. .PP
  950. A six byte
  951. framing
  952. .I
  953. envelope
  954. .R
  955. is constructed using the control byte
  956. C of a packet and five other bytes as
  957. depicted below.
  958. .in +1i
  959. <DLE><k><c0><c1><C><x>
  960. .in -1i
  961. The <DLE> symbol denotes the ASCII ctrl/P character.
  962. If the envelope is to be followed by a data segment,
  963. <k> has the value
  964. log\d2\u(size)-4;
  965. i.e. 1 \(<= k \(<= 8.
  966. If k is 9, then the envelope represents a control packet.
  967. The <c0> and <c1> bytes are the low-order and high-order
  968. bytes respectively of a 16-bit checksum of the data segment,
  969. if there is one.
  970. For control packets <c1> is zero and <c0> is the same
  971. as the control byte C.
  972. The <x> byte is the exclusive-or of <k><c0><c1><C>.
  973. Error control is accomplished by checking 
  974. a received framing envelope for compliance with the definition,
  975. and comparing a checksum function of the data segment
  976. with <c0><c1>.
  977. .PP
  978. This particular framing strategy assumes data segments
  979. are constant-sized:
  980. the `unused' bytes in a short packet are actually
  981. transmitted.
  982. This creates a certain amount of overhead which
  983. can be eliminated by a more complicated framing technique.
  984. The advantage of this strategy is that i/o
  985. devices can be programmed to take advantage of the
  986. constant-sized framing envelopes and data segments.
  987. .bp
  988. .PP
  989. The checksum calculation is displayed below as a C function.
  990. Note that the code is not truly portable because
  991. the definitions of
  992. .I short
  993. and
  994. .I char
  995. are not necessarily uniform across all machines
  996. that might support this language.
  997. This code assumes that
  998. .I short
  999. and
  1000. .I char
  1001. are 16 and 8-bits respectively.
  1002. .PP
  1003. .in +.5i
  1004. .nf
  1005. .ft CW
  1006. .ls 1
  1007. /* [Original document's version corrected to actual version] */
  1008. chksum(s,n)
  1009. register char *s;
  1010. register n;
  1011. {
  1012.     register short sum;
  1013.     register unsigned short t;
  1014.     register short x;
  1015.  
  1016.     sum = -1;
  1017.     x = 0;
  1018.  
  1019.     do {
  1020.         if (sum<0) {
  1021.             sum <<= 1;
  1022.             sum++;
  1023.         } else
  1024.             sum <<= 1;
  1025.         t = sum;
  1026.         sum += (unsigned)*s++ & 0377;
  1027.         x += sum^n;
  1028.         if ((unsigned short)sum <= t) {
  1029.             sum ^= x;
  1030.         }
  1031.     } while (--n > 0);
  1032.  
  1033.     return(sum);
  1034. }
  1035. .fi
  1036. .in -.5i
  1037. .ft R
  1038. -- 
  1039. John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   gnu@ingres.berkeley.edu
  1040. Love your country but never trust its government.
  1041.              -- from a hand-painted road sign in central Pennsylvania
  1042.  
  1043.  
  1044.